package com.fept.msgcore.msgserver.senderinfo;

import com.fept.msgcore.msgserver.common.model.ToString;
import com.fept.msgcore.msgserver.protocol.model.option.EncryptOption;
import com.fept.msgcore.msgserver.protocol.model.option.SignOption;

import java.util.Random;

/**
 * Created by Srma on 2/9/2017.
 */
public class SenderStatMachine extends ToString {

    /**
     *
     */
    private static final long serialVersionUID = -1531957030438342220L;
    private static final Random random = new Random();

    private static final int WRAP = 0x10000;

    /**
     * 状态控制
     */
    private int id = random.nextInt(WRAP);
    /**
     * 默认使用HMAC_SHA1
     */
    private int signAlgorithm = SignOption.HMAC_SHA1;
    private int signKey = 0;
    private int encryptAlgorithm = EncryptOption.AES;
    private int encryptKey = 0;

    /**
     *
     * @return
     */
    public int nextID() {
        this.id = (this.id + 1) % WRAP;
        return this.id;
    }

    /**
     * @return the id
     */
    public int getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(int id) {
        this.id = id;
    }

    /**
     * @return the signAlgorithm
     */
    public int getSignAlgorithm() {
        return signAlgorithm;
    }

    /**
     * @param signAlgorithm
     *            the signAlgorithm to set
     */
    public void setSignAlgorithm(int signAlgorithm) {
        this.signAlgorithm = signAlgorithm;
    }

    /**
     * @return the signKey
     */
    public int getSignKey() {
        return signKey;
    }

    /**
     * @param signKey
     *            the signKey to set
     */
    public void setSignKey(int signKey) {
        this.signKey = signKey;
    }

    /**
     * @return the encryptAlgorithm
     */
    public int getEncryptAlgorithm() {
        return encryptAlgorithm;
    }

    /**
     * @param encryptAlgorithm
     *            the encryptAlgorithm to set
     */
    public void setEncryptAlgorithm(int encryptAlgorithm) {
        this.encryptAlgorithm = encryptAlgorithm;
    }

    /**
     * @return the encryptKey
     */
    public int getEncryptKey() {
        return encryptKey;
    }

    /**
     * @param encryptKey
     *            the encryptKey to set
     */
    public void setEncryptKey(int encryptKey) {
        this.encryptKey = encryptKey;
    }
}
